var arrayDestructuringHelper = function(array, limit) {
    if (Array.isArray(array)) return array;
    if (Symbol.iterator in Object(array)) return function(array, limit) {
        var result = [], shouldContinue = !0, hasError = !1, error = void 0;
        try {
            for (var item, iterator = array[Symbol.iterator](); !(shouldContinue = (item = iterator.next()).done) && (result.push(item.value), 
            !limit || result.length !== limit); shouldContinue = !0) ;
        } catch (error) {
            hasError = !0, error = error;
        } finally {
            try {
                !shouldContinue && iterator.return && iterator.return();
            } finally {
                if (hasError) throw error;
            }
        }
        return result;
    }(array, limit);
    throw new TypeError("Invalid attempt to destructure non-iterable instance");
};

(0, require("../common/component").VantComponent)({
    props: {
        text: {
            type: String,
            value: ""
        },
        mode: {
            type: String,
            value: ""
        },
        url: {
            type: String,
            value: ""
        },
        openType: {
            type: String,
            value: "navigate"
        },
        delay: {
            type: Number,
            value: 1
        },
        speed: {
            type: Number,
            value: 50
        },
        scrollable: {
            type: Boolean,
            value: !0
        },
        leftIcon: {
            type: String,
            value: ""
        },
        color: {
            type: String,
            value: "#ed6a0c"
        },
        backgroundColor: {
            type: String,
            value: "#fffbe8"
        },
        wrapable: Boolean
    },
    data: {
        show: !0
    },
    watch: {
        text: function() {
            this.set({}, this.init);
        }
    },
    created: function() {
        this.resetAnimation = wx.createAnimation({
            duration: 0,
            timingFunction: "linear"
        });
    },
    destroyed: function() {
        this.timer && clearTimeout(this.timer);
    },
    methods: {
        init: function() {
            var componentInstance = this;
            Promise.all([ componentInstance.getRect(".van-notice-bar__content"), componentInstance.getRect(".van-notice-bar__wrap") ]).then(function(rectangles) {
                var destructuredRectangles = arrayDestructuringHelper(rectangles, 2), contentRect = destructuredRectangles[0], wrapRect = destructuredRectangles[1];
                if (null != contentRect && null != wrapRect && contentRect.width && wrapRect.width) {
                    var data = componentInstance.data, scrollSpeed = data.speed, isScrollable = data.scrollable, delayDuration = data.delay;
                    if (isScrollable && wrapRect.width < contentRect.width) {
                        var animationDuration = contentRect.width / scrollSpeed * 1e3;
                        componentInstance.wrapWidth = wrapRect.width, componentInstance.contentWidth = contentRect.width, componentInstance.duration = animationDuration, componentInstance.animation = wx.createAnimation({
                            duration: animationDuration,
                            timingFunction: "linear",
                            delay: delayDuration
                        }), componentInstance.scroll();
                    }
                }
            });
        },
        scroll: function() {
            var componentInstance = this;
            componentInstance.timer && clearTimeout(componentInstance.timer), componentInstance.timer = null, componentInstance.set({
                animationData: componentInstance.resetAnimation.translateX(componentInstance.wrapWidth).step().export()
            }), setTimeout(function() {
                componentInstance.set({
                    animationData: componentInstance.animation.translateX(-componentInstance.contentWidth).step().export()
                });
            }, 20), componentInstance.timer = setTimeout(function() {
                componentInstance.scroll();
            }, componentInstance.duration);
        },
        onClickIcon: function() {
            this.timer && clearTimeout(this.timer), this.timer = null, this.set({
                show: !1
            });
        },
        onClick: function(event) {
            this.$emit("click", event);
        }
    }
});